/*
 * @Author: luoqi
 * @Date: 2021-05-26 16:10:33
 * @ Modified by: luoqi
 * @ Modified time: 2024-10-11 22:30
 */

#ifndef _QTERM_H
#define _QTERM_H

#include <bsp.h>
#include "qcli.h"

#define QSH(...)                bsp_printf(__VA_ARGS__)
#define ISARG(str1, str2)       (isarg(str1, str2) == 0)
#define ARG_ERR(lable)          bsp_printf(" [%s] #! Arg error\r\n", lable)
#define PRINT_HEX(ptr, size)     do{                                                         \
                                        tx_mutex_get(&_mtx_print, TX_WAIT_FOREVER);          \
                                        for(int i = 0; i < size; i++){                       \
                                            bsp_printf(" %02X", ptr[i]);                     \
                                        }                                                    \
                                        bsp_printf("\r\n");                                  \
                                        tx_mutex_put(&_mtx_print);                           \
                                    } while(0)

int isarg(const char *s, const char *arg);

int qterm_init(void);

int qterm_exec(char c);

int qterm_call(char *args);

int qterm_attach(QCliCmd *cmd, const char *name, QCliCallback callback, const char *usage);

int qterm_detach(QCliCmd *cmd);

#endif
